package net.hn.hnms.biz.safety.wind.Service;

import net.hn.hnms.biz.safety.wind.Dao.WindWindowDao;
import net.hn.hnms.biz.safety.wind.Dao.WindWindowDetailsDao;
import net.hn.hnms.biz.safety.wind.entity.WindWindowDetailsEntity;
import net.hn.hnms.biz.safety.wind.entity.WindWindowEntity;
import net.hn.hnms.biz.safety.wind.entity.WindWindowVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 智呈物联 nzw
 * @date 2022/12/21
 */

@Service
public class WindWindowService {
    private WindWindowDao windWindowDao;

    private WindWindowDetailsDao windWindowDetailsDao;

    private PositionService positionService;

    @Autowired
    public void setWindWindowDao(WindWindowDao windWindowDao) {
        this.windWindowDao = windWindowDao;
    }

    @Autowired
    public void setWindWindowDetailsDao(WindWindowDetailsDao windWindowDetailsDao) {
        this.windWindowDetailsDao = windWindowDetailsDao;
    }

    @Autowired
    public void setPositionService(PositionService positionService) {
        this.positionService = positionService;
    }

    public List<WindWindowVO> findWindWindow(String mineCode){
        List<WindWindowEntity> windWindowEntityList = windWindowDao.findAllByMineCode(mineCode);
        List<WindWindowVO> windWindowVOList = new ArrayList<>();

        for (WindWindowEntity windowEntity:windWindowEntityList){
            WindWindowVO windWindowVO = new WindWindowVO();

            windWindowVO.setVideoChannelId(windowEntity.getVideoChannelId());
            windWindowVO.setPositionName(positionService.getPositionName(windowEntity.getPositionId()));
            List<WindWindowDetailsEntity> windWindowDetailsEntityList = windWindowDetailsDao.findByWindWindowId(windowEntity.getId());

            for (WindWindowDetailsEntity windWindowDetailsEntity:windWindowDetailsEntityList){

                windWindowVO.setOpeningCurrentAngle(windWindowDetailsEntity.getOpeningCurrentAngle());
                windWindowVO.setWindWindowSectionalArea(windWindowDetailsEntity.getWindWindowSectionalArea());
                windWindowVO.setWindWindowName(windWindowDetailsEntity.getWindWindowName());
                windWindowVOList.add(windWindowVO);
            }

        }
        return windWindowVOList;
    }
}
